fix(table): preserve workflow groups on CSV column-add and dispatch after tx commit#4503
fix(table): preserve workflow groups on CSV column-add and dispatch after tx commit#4503TheodoreSpeaks wants to merge 1 commit intostagingfrom
Conversation
…fter tx commit Two bugs in the CSV-import path: - addTableColumnsWithTx rebuilt the schema with only `columns`, dropping `workflowGroups` (and any other top-level schema fields). Importing CSV into a table that has workflow groups erased the group config. Spread `table.schema` first so siblings survive. - batchInsertRowsWithTx fired fireTableTrigger and scheduleRunsForRows from inside the caller's transaction. Both read through the global db connection, so they could run before the inserts committed and see no rows. Extracted the dispatch into dispatchAfterBatchInsert; non-tx wrapper fires it after `db.transaction(...)` resolves, and the CSV import route does the same after its tx.
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
PR SummaryMedium Risk Overview
Insert side-effects are moved to a new Reviewed by Cursor Bugbot for commit 50817dc. Bugbot is set up for automated code reviews on this repo. Configure here. |
Greptile SummaryThis PR patches two related bugs in the table CSV-import path.
Confidence Score: 4/5Safe to merge — both bug fixes are well-scoped and correct; the only gap is a missing assertion in the test suite. The schema spread in addTableColumnsWithTx correctly preserves workflowGroups, and dispatchAfterBatchInsert is called after db.transaction resolves in both the non-tx wrapper and the CSV append route. The only weak spot is that route.test.ts registers mockDispatchAfterBatchInsert but never asserts it was called, so a future regression dropping the dispatch call would go undetected. apps/sim/app/api/table/[tableId]/import/route.test.ts — happy-path tests should assert dispatchAfterBatchInsert is invoked Important Files Changed
Sequence DiagramsequenceDiagram
participant Route as CSV Import Route
participant DB as db.transaction
participant Service as service (Tx helpers)
participant Trigger as fireTableTrigger / scheduleRunsForRows
Route->>DB: begin transaction
DB->>Service: addTableColumnsWithTx (schema spread fix)
Service-->>DB: updated table (workflowGroups preserved)
DB->>Service: batchInsertRowsWithTx x N batches
Service-->>DB: allInserted rows
DB-->>Route: inserted rows + finalTable
Note over DB: transaction committed
Route->>Trigger: dispatchAfterBatchInsert(finalTable, insertedRows) - runs AFTER commit
|
Summary
Type of Change
Testing
`bunx vitest run lib/table app/api/table` — 151/151 pass. Lint clean.
Checklist